<!-- 留言Item -->
<template>
	<view class="comment_item">
		<view class="item" v-for="(item,index) in list" :key="index">
			<view class="left"><image :src="item.url"></image></view>
			<view class="center">
				<view class='top'>
					<view class="name">{{item.name}}</view>
					<view v-if="item.isAuther" class="auther">作者</view>
				</view>
				<view class="content">
					{{item.content}}
				</view>
				<view class="bot">
					<text class="time">{{item.time}}</text>
					<text>IP:{{item.ip}}</text>
					<text class="hf">回复</text>
				</view>
				
				 <u-transition :show="item.isShowSon" mode="fade">
					<view class="son">
						<view class="son_item" v-for="(son,index2) in item.son" :key="index2">
							<view class="son_left">
								<image :src="son.sonUrl"></image>
							</view>
							<view class="son_right">
								<view class="name">{{son.sonName}}</view>
								<view class="content">{{son.sonContent}}</view>
								<view class="ip">
									<view class="sonTime">{{son.sonTime}}</view>
									<view >ip:{{son.sonIp}}</view>
								</view>
							</view>
						</view>
					</view>
				</u-transition>
				
				<view class="more" @click="showMore(index,'more')" v-if="!item.isShowSon">
					<view class="left"><text class="line">____ </text>展开{{item.num}}条回复</view>	<u-icon name="arrow-down" size="30rpx"></u-icon>
				</view>
				
				<view class="few" @click="showMore(index,'few')" v-else>
					<view class="left"><text>收起</text>	<u-icon name="arrow-up" size="30rpx"></u-icon></view>
				</view>
				
			</view>
			<view class="right">
				<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/mine/zan.png"></image>
				<text>{{item.zan}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		props:{
			dataList:{
				type:Array,
				default:() => []
			}
		},
		watch:{
				dataList:{
					handler(){
						this.getList();
					},
					deep:true
			}
		},
		mounted(){
			this.getList();
		},
		data(){
			return {
				list:[]
			}
		},
		methods:{
			//收起还是展开
			showMore(index,name){
				this.list[index].isShowSon = name == 'more';
			},
			getList(){
				this.list = this.dataList.map(item => {
					return {
						isShowSon:false,
						...item,
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.comment_item{
		.item{
			display: flex;
			justify-content: space-between;
			margin-top:40rpx;
			align-items: flex-start;
			.left{
				margin-right:16rpx;
				image{
					width: 72rpx;
					height: 72rpx;
					border-radius: 50%;
				}
			}
			.center{
				width: 510rpx;
				.top{
					display: flex;
					align-items: center;
					.name{
						font-size: 26rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: #747474;
					}
					.auther{
						width: 76rpx;
						height: 42rpx;
						background: #FFFFFF;
						border: 2rpx solid #194FC9;
						border-radius: 20rpx;
						font-size: 24rpx;
						font-family: Source Han Sans CN;
						font-weight: 500;
						color: #369CFE;
						line-height: 42rpx;
						margin-left:14rpx;
						text-align: center;
					}
				}
			
				.content{
					line-height: 44rpx;
					font-size: 30rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #2B2B2B;
				}
				.bot{
					margin-top:22rpx;
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #B4B4B4;
					display: flex;
					align-items: center;
					.hf{
						margin-left:72rpx;
						font-family: Source Han Sans CN;
						font-weight: 500;
						color: #878787;
					}
					.time{
						margin-right:18rpx;
					}
				}
			}
			.right{
				display: flex;
				align-items: center;
				image{
					width: 42rpx;
					height: 30rpx;
				}
				text{
					margin-left:6rpx;
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
				}
			}
		
			.more,.few{
				margin-top:38rpx;
				display: flex;
				align-items: center;
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 500;
				color: #878787;
				.line{				
					color: #E4E4E4;
					margin-right:10rpx;
				}
				.left{
					margin-right:10rpx;
				}
			}
			.few{
				justify-content: center;
				.left{
					display: flex;
					align-items: center;
					text{
						margin-right: 10rpx;
					}
				}
			}
		
			.son_item{
				margin-top:36rpx;
				display: flex;
				align-items: flex-start;
				.son_left{
					margin-right:16rpx;
					image{
						width: 40rpx;
						height: 40rpx;
						border-radius: 50%;
					}
				}
				.son_right{
					.name{
						font-size: 26rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: #747474;
					}
					.content{
						font-size: 30rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						line-height: 44rpx;
						color: #2B2B2B;
						margin:14rpx 0 24rpx;
					}
					.ip{
						font-size: 26rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #B4B4B4;
						display: flex;
						align-items: center;
						.sonTime{
							margin-right: 18rpx;
						}
					}
				}
			}
		}
	}
</style>